package com.geostar.constructionland.attachment.service;

import com.geostar.constructionland.attachment.entity.FileObject;
import com.mongodb.client.gridfs.model.GridFSFile;
import com.mongodb.gridfs.GridFSDBFile;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;

public interface MongoGridFsService {

    /*----------增----------*/

    /**
     * 上传文件 保存
     */
    void uploadFile(File file, FileObject fileObject) throws IOException;

    /*----------删----------*/

    /**
     * 根据fileId删除文件
     */
    void deleteByFileId(String fileId);

    /**
     * 根据fileId删除批量文件
     */
    void deleteByFileIds(String[] fileIds);

    void deleteByFolderId(String folderId);

    void deleteInStatus(String fileId, String status);

    /*----------改----------*/
    long invalidBySrcId(String sourceId);

    long shareFile(String fileId);

    long shareFiles(String[] fileIds);

    long unshareFile(String fileId);

    long unshareFiles(String[] fileIds);

    void updateTextContent(String fileId, String textContent);

    /**
     * 改变文件的状态
     * 也就是更新status字段
     *
     * @return
     */
    long switchFileStatus(String fileId, String from, String to);

    /*----------查----------*/
    GridFSDBFile downLoadFileByFileId(String fileId);

    FileObject getFileMetadataByFileId(String fileId) throws IllegalAccessException, InvocationTargetException;

    List<FileObject> listFileMetadataByFolderId(String folderId);

    List<FileObject> listFileMetadataByFolderIdAndFileName(String folderId, String fileName);

    List<FileObject> listFileMetadataByFileIds(String[] fileIds) throws IllegalAccessException, InvocationTargetException;

    Map<String, Object> getAllByFileId(String fileId) throws IllegalAccessException, InvocationTargetException;

    List<FileObject> getIsShareFiles();

    List<FileObject> getMyIsShareFiles(String userId);

    List<FileObject> getMyValidFiles(String indentifyId, String userId);


}
